//
//  FKMySettingVC.m
//  HappyTest
//
//  Created by Macbook Pro on 2019/1/14.
//  Copyright © 2019 Macbook Pro. All rights reserved.
//

#import "FKMySettingVC.h"
#import "FKModifyLoginPwdVC.h"
#import "FKPayPwdManageVC.h"
#import "FKFeedbackVC.h"
#import "FKWebViewVC.h"
#import "FKAboutUsVC.h"

@interface FKMySettingVC ()

@property (weak, nonatomic) IBOutlet UILabel *payPwdStatusLabel;
@property (weak, nonatomic) IBOutlet UILabel *versionLabel;
@property (nonatomic, copy) NSString *appVersion;

@end

@implementation FKMySettingVC

- (instancetype)init
{
    return [UIStoryboard storyboardWithName:@"FKMySettingVC" bundle:nil].instantiateInitialViewController;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.versionLabel.text = fkFORMAT(@"V %@", [[UIApplication sharedApplication] fk_appVersion]);
    NSLog(@"---(%d)---", [FKCacheTool isHasPayPwd]);
    self.payPwdStatusLabel.text = [FKCacheTool isHasPayPwd] ? @"已设置" : @"未设置";
}

#pragma mark - Table view data source
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return fk_adjustW(50);
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0.01;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        if ([FKCacheTool isHasPayPwd]) {
            FKPayPwdManageVC *vc = [UIStoryboard storyboardWithName:@"FKPayPwdManageVC" bundle:nil].instantiateInitialViewController;
            fkPushNav(vc);
        } else {
            fkPushNav([[NSClassFromString(@"FKSetPayPwdVC") alloc] init]);
        }
    } else if (indexPath.row == 1) {
        FKAboutUsVC *vc = [[FKAboutUsVC alloc] init];
        fkPushNav(vc);
    } else if (indexPath.row == 2) {
        [SVProgressHUD show];
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.25 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            [SVProgressHUD showSuccessWithStatus:@"缓存清除成功"];
        });
    } else if (indexPath.row == 3) {
        
    }
}

- (IBAction)logoutBtnClicked:(UIButton *)sender
{
    fkWeakSelf(self);
    [self fk_alertWithTitle:@"确定要退出登陆吗?" confirm:^{
        [FKCacheTool saveLoginInfo:nil];
        [FKCacheTool saveUserInfo:nil];
        
//        [FKLoginTool showLoginBySwitchRootVC];
        
        [FKLoginTool checkLogin:nil];
        [[NSNotificationCenter defaultCenter] postNotificationName:@"changeTabBar" object:nil];
        weakself.tabBarController.selectedIndex = 0;
        [weakself.navigationController popToRootViewControllerAnimated:false];
    }];
}



@end
